package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketFootprint;
import com.cskaoyan.market.db.domain.MarketFootprintExample;
import com.cskaoyan.market.db.mapper.MarketFootprintMapper;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/7 17:04
 */
@Service
public class MarketFootPrintServiceImpl implements MarketFootPrintService {
    @Autowired
    MarketFootprintMapper mapper;
    @Override
    public List<MarketFootprint> list(Integer limit, Integer page, String order, String sort, String userId, String goodsId) {
        MarketFootprintExample marketFootprintExample=new MarketFootprintExample();
        marketFootprintExample.setOrderByClause(sort+" "+order);
        MarketFootprintExample.Criteria criteria= marketFootprintExample.createCriteria();
        if(!StringUtils.isEmpty(userId)){
            criteria.andUserIdEqualTo(Integer.valueOf(userId));

        }
        if(!StringUtils.isEmpty(goodsId)){
            criteria.andGoodsIdEqualTo(Integer.valueOf(goodsId));
        }
        PageHelper.startPage(page,limit);
        criteria.andLogicalDeleted(true);
        List<MarketFootprint> marketFootprints=mapper.selectByExampleSelective(marketFootprintExample,MarketFootprint.Column.id,MarketFootprint.Column.userId,MarketFootprint.Column.goodsId,MarketFootprint.Column.updateTime,MarketFootprint.Column.deleted);

        return marketFootprints;


    }
}
